/*
 * @LastEditTime: 2023-03-18 11:19:00
 * @Method: 
 * @Description: 
 */
package Preview.meituan;

import java.util.Arrays;
import java.util.Scanner;

public class Main4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[][] nums = new int[N][2];
        for (int i = 0;i < N;i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nums[i] = new int[]{a, b};
        }
        Arrays.sort(nums, (o1, o2) -> {
            if (o1[1] != o2[1]) {
                return Integer.compare(o1[1], o2[1]);
            } else {
                return Integer.compare(o2[0], o1[0]);
            }
            
        });
        // for (int i = 0;i < N;i++) {
        //     System.out.println(Arrays.toString(nums[i]));
        // }
        int money = 0;
        int num = 0;
        for (int i = 0;i < N;i++) {
            int[] item = nums[i];
            if (Y > 0 && money + item[1] <= X) {
                money += item[1];
                num++;
                Y--;
            } else if (money + item[0] <= X) {
                money += item[0];
                num++;
            } else if (money + item[0] > X || money + item[1] > X) {
                break;
            }
        }
        System.out.println(num + " " + money);
    }
}
